<%@page import="entity.Grade"%>
<%@page import="service.GradeService"%>
<%@page import="service.impl.GradeServiceimp"%>
<%@page import="entity.Student"%>
<%@page import="java.util.List"%>
<%@page import="service.StudentService"%>
<%@page import="service.impl.StudentServiceimp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生信息列表</title>
<link href="${pageContext.request.contextPath }/css/common.css" rel="stylesheet" type="text/css" />

</head>
<body>

<h2>学生信息</h2>


<table>
  <tr>
    <td class="listTable">编号</td>
    <td class="listTable">姓名</td>
    <td class="listTable">性别</td>
    <td class="listTable">年龄</td>
    <td class="listTable">年级</td>
    <td id="operate">操作</td>
  </tr>

<%
   session.removeAttribute("list");
   StudentService stuService = new StudentServiceimp();
   GradeService gradeService = new GradeServiceimp();
   Grade grade = new Grade();
   List<Student> list = stuService.getAllStudent();
   session.setAttribute("list", list);
   for(Student stu:list){
    grade.setGradeId(stu.getGradeId());
    grade = gradeService.getGrade(grade);
 %>

  <tr>
   <td><%=stu.getId() %> </td><td><%=stu.getName() %> </td>
   <td><%=stu.getSex() %> </td>
   <td><%=stu.getAge() %> </td>
   <td><%=grade.getGradeName() %></td>

   <td><a href="stuDetail.jsp?id=<%=stu.getId() %>">查看&nbsp;&nbsp;</a>
  </td>
  </tr>
<%} %>






</table>
<div class="head">欢迎你，${user.username } &nbsp;&nbsp;&nbsp;<a href="logout.jsp">退出</a></div>

</body>
</html>